﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Idiom.Migrations
{
    public partial class sss : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "IdiomModels",
                columns: table => new
                {
                    IdiomModelId = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Character = table.Column<string>(nullable: false),
                    Pinyin = table.Column<string>(nullable: true),
                    Interpretation = table.Column<string>(nullable: true),
                    Originate = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_IdiomModels", x => x.IdiomModelId);
                });

            migrationBuilder.CreateTable(
                name: "Relevants",
                columns: table => new
                {
                    RelevantId = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    BelongIdiomModelId = table.Column<int>(nullable: true),
                    ModelIdiomModelId = table.Column<int>(nullable: true),
                    IdiomModelId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Relevants", x => x.RelevantId);
                    table.ForeignKey(
                        name: "FK_Relevants_IdiomModels_BelongIdiomModelId",
                        column: x => x.BelongIdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Relevants_IdiomModels_IdiomModelId",
                        column: x => x.IdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Relevants_IdiomModels_ModelIdiomModelId",
                        column: x => x.ModelIdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Sentences",
                columns: table => new
                {
                    SentenceId = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    SentenceContent = table.Column<string>(nullable: false),
                    BlongIdiomModelId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Sentences", x => x.SentenceId);
                    table.ForeignKey(
                        name: "FK_Sentences_IdiomModels_BlongIdiomModelId",
                        column: x => x.BlongIdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "Similas",
                columns: table => new
                {
                    SimilarId = table.Column<int>(nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    BelongIdiomModelId = table.Column<int>(nullable: true),
                    ModelIdiomModelId = table.Column<int>(nullable: true),
                    IdiomModelId = table.Column<int>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Similas", x => x.SimilarId);
                    table.ForeignKey(
                        name: "FK_Similas_IdiomModels_BelongIdiomModelId",
                        column: x => x.BelongIdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Similas_IdiomModels_IdiomModelId",
                        column: x => x.IdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_Similas_IdiomModels_ModelIdiomModelId",
                        column: x => x.ModelIdiomModelId,
                        principalTable: "IdiomModels",
                        principalColumn: "IdiomModelId",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_Relevants_BelongIdiomModelId",
                table: "Relevants",
                column: "BelongIdiomModelId");

            migrationBuilder.CreateIndex(
                name: "IX_Relevants_IdiomModelId",
                table: "Relevants",
                column: "IdiomModelId");

            migrationBuilder.CreateIndex(
                name: "IX_Relevants_ModelIdiomModelId",
                table: "Relevants",
                column: "ModelIdiomModelId");

            migrationBuilder.CreateIndex(
                name: "IX_Sentences_BlongIdiomModelId",
                table: "Sentences",
                column: "BlongIdiomModelId");

            migrationBuilder.CreateIndex(
                name: "IX_Similas_BelongIdiomModelId",
                table: "Similas",
                column: "BelongIdiomModelId");

            migrationBuilder.CreateIndex(
                name: "IX_Similas_IdiomModelId",
                table: "Similas",
                column: "IdiomModelId");

            migrationBuilder.CreateIndex(
                name: "IX_Similas_ModelIdiomModelId",
                table: "Similas",
                column: "ModelIdiomModelId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Relevants");

            migrationBuilder.DropTable(
                name: "Sentences");

            migrationBuilder.DropTable(
                name: "Similas");

            migrationBuilder.DropTable(
                name: "IdiomModels");
        }
    }
}
